home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / OpenTptAppleTalk.p < prev    next >
Encoding:
Text File  |  1996-02-13  |  11.2 KB  |  341 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTptAppleTalk.p
  3.  
  4.      Contains:    Public AppleTalk definitions
  5.  
  6.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.  UNIT OpenTptAppleTalk;
  17.  INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED __OPENTPTAPPLETALK__}
  21. {$SETC __OPENTPTAPPLETALK__ := 1}
  22.  
  23. {$I+}
  24. {$SETC OpenTptAppleTalkIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26.  
  27.  
  28. {$IFC UNDEFINED __OPENTRANSPORT__}
  29. {$I OpenTransport.p}
  30. {$ENDC}
  31. {    Types.p                                                        }
  32. {        ConditionalMacros.p                                        }
  33. {    MixedMode.p                                                    }
  34. {    Strings.p                                                    }
  35.  
  36. {$PUSH}
  37. {$ALIGN MAC68K}
  38. {$LibExport+}
  39.  
  40. CONST
  41.     ATK_DDP                        = 'DDP ';
  42.     ATK_AARP                    = 'AARP';
  43.     ATK_ATP                        = 'ATP ';
  44.     ATK_ADSP                    = 'ADSP';
  45.     ATK_ASP                        = 'ASP ';
  46.     ATK_PAP                        = 'PAP ';
  47.     ATK_NBP                        = 'NBP ';
  48.     ATK_ZIP                        = 'ZIP ';
  49.  
  50. {******************************************************************************
  51. ** Some prefixes for shared libraries
  52. *******************************************************************************}
  53.     kATalkVersion    =    '1.0';
  54.     kATalkPrefix        =    'ot:atlk$';
  55.     kATBinderID        =    'ot:atbd$';
  56. {}
  57. { Module Names}
  58. {}
  59.     kDDPName                    = 'ddp';
  60.     kATPName                    = 'atp';
  61.     kADSPName                    = 'adsp';
  62.     kASPName                    = 'asp';
  63.     kPAPName                    = 'pap';
  64.     kNBPName                    = 'nbp';
  65.     kZIPName                    = 'zip';
  66.     kLTalkName                    = 'ltlk';
  67.     kLTalkAName                    = 'ltlkA';
  68.     kLTalkBName                    = 'ltlkB';
  69.  
  70. {******************************************************************************
  71. ** Protocol-specific Options
  72. **
  73. ** NOTE:
  74. ** All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  75. ** ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  76. **                OPT_INTERVAL (# Milliseconds to wait)
  77. *******************************************************************************}
  78.     DDP_OPT_CHECKSUM            = OPT_CHECKSUM;
  79.     DDP_OPT_SRCADDR                = 0x2101;
  80.     ATP_OPT_REPLYCNT            = $2110;                        { AppleTalk - ATP Resp Pkt Ct Type            }
  81. { Value is (unsigned long)  pkt count        }
  82.     ATP_OPT_DATALEN                = $2111;                        { AppleTalk - ATP Pkt Data Len Type        }
  83. { Value is (unsigned long) length            }
  84.     ATP_OPT_RELTIMER            = $2112;                        { AppleTalk - ATP Release Timer Type
  85.                                      * Value is (unsigned long) timer
  86.                                      * (See Inside AppleTalk, second edition    }
  87.     ATP_OPT_TRANID                = $2113;                        { Value is (unsigned long) Boolean            }
  88.     PAP_OPT_OPENRETRY            = $2120;                        { AppleTalk - PAP OpenConn Retry count
  89.                                      * Value is (unsigned long) T_YES/T_NO        }
  90.  
  91. {******************************************************************************
  92. ** Protocol-specific events
  93. *******************************************************************************}
  94.     kAppleTalkEvent                = kPROTOCOLEVENT + $10000;
  95. {
  96.      * If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  97.      * you will receive these events on your endpoint.
  98.      * NOTE: The endpoint does not need to be bound.
  99.      *
  100.      * No routers have been seen for a while.  If the cookie is NULL,
  101.      * all routers are gone.  Otherwise, there is still an ARA router
  102.      * hanging around being used, and only the local cable has been 
  103.      * timed out.
  104.      }
  105.     T_ATALKROUTERDOWNEVENT        = kAppleTalkEvent + 51;
  106. {
  107.          * This indicates that all routers are offline
  108.          }
  109.     kAllATalkRoutersDown        = 0;
  110. {
  111.          * This indicates that all local routers went offline, but
  112.          * an ARA router is still active
  113.          }
  114.     kLocalATalkRoutersDown        = -1;
  115. {
  116.          * This indicates that ARA was disconnected, do it's router went offline,
  117.          * and we have no local routers to fall back onto.
  118.          }
  119.     kARARouterDisconnected        = -2;
  120. {
  121.      * We didn't have a router, but now one has come up.
  122.      * Cookie is NULL for a normal router coming up, non-NULL
  123.      * for an ARA router coming on-line
  124.      }
  125.     T_ATALKROUTERUPEVENT        = kAppleTalkEvent + 52;
  126. {
  127.          * We had no local routers, but an ARA router is now online.
  128.          }
  129.     kARARouterOnline            = -1;
  130. {
  131.          * We had no routers, but a local router is now online
  132.          }
  133.     kATalkRouterOnline            = 0;
  134. {
  135.          * We have an ARA router, but now we've seen a local router as well
  136.          }
  137.     kLocalATalkRouterOnline        = -2;
  138. {
  139.      * A Zone name change was issued from the router, so our
  140.      * AppleTalk Zone has changed.
  141.      }
  142.     T_ATALKZONENAMECHANGEDEVENT    = kAppleTalkEvent + 53;
  143. {
  144.      * An ARA connection was established (cookie != NULL),
  145.      * or was disconnected (cookie == NULL)
  146.      }
  147.     T_ATALKCONNECTIVITYCHANGEDEVENT = kAppleTalkEvent + 54;
  148. {
  149.      * A router has appeared, and our address is in the startup
  150.      * range.  Cookie is hi/lo of new cable range.
  151.      }
  152.     T_ATALKINTERNETAVAILABLEEVENT = kAppleTalkEvent + 55;
  153. {
  154.      * A router has appeared, and it's incompatible withour
  155.      * current address.  Cookie is hi/lo of new cable range.
  156.      }
  157.     T_ATALKCABLERANGECHANGEDEVENT = kAppleTalkEvent + 56;
  158.  
  159. {    -------------------------------------------------------------------------
  160.         ECHO
  161.         ------------------------------------------------------------------------- }
  162.     kECHO_TSDU                    = 585;                            { Max. # of data bytes.}
  163. {    -------------------------------------------------------------------------
  164.         NBP
  165.         ------------------------------------------------------------------------- }
  166.     kNBPMaxNameLength            = 32;
  167.     kNBPMaxTypeLength            = 32;
  168.     kNBPMaxZoneLength            = 32;
  169.     kNBPSlushLength                = 9;                            { Extra space for @, : and a few escape chars}
  170.     kNBPMaxEntityLength            = 0+(kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + 3);
  171.     kNBPEntityBufferSize        = 0+(kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + kNBPSlushLength);
  172.     kNBPWildCard                = $3D;                            { NBP name and type match anything '='}
  173.     kNBPImbeddedWildCard        = $C5;                            { NBP name and type match some '≈'}
  174.     kNBPDefaultZone                = $2A;                            { NBP default zone '*'}
  175. {    -------------------------------------------------------------------------
  176.         ZIP
  177.         ------------------------------------------------------------------------- }
  178.     kZIPMaxZoneLength            = kNBPMaxZoneLength;
  179. {    -------------------------------------------------------------------------
  180.         Address-related values
  181.         ------------------------------------------------------------------------- }
  182.     kDDPAddressLength            = 8;                            { value to use in netbuf.len field}
  183. { Maximum length of AppleTalk address}
  184.     kNBPAddressLength            = kNBPEntityBufferSize;
  185.     kAppleTalkAddressLength        = kDDPAddressLength + kNBPEntityBufferSize;
  186.  
  187. {******************************************************************************
  188. ** CLASS TAppleTalkServices
  189. *******************************************************************************}
  190. {$IFC NOT OTKERNEL }
  191. {$IFC UNDEFINED __cplusplus }
  192.     
  193. TYPE
  194.     ATSvcRef = Ptr;
  195.  
  196. {$ELSEC}
  197.  
  198. TYPE
  199.     TAppleTalkServices = RECORD
  200.     END;
  201.  
  202.     ATSvcRef = ^TAppleTalkServices;
  203.  
  204. {$ENDC}
  205. {$SETC kDefaultAppleTalkServicesPath := (-3)}
  206.  
  207. FUNCTION OTAsyncOpenAppleTalkServices(VAR cfig: OTConfiguration; flags: OTOpenFlags; notifyProc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  208. FUNCTION OTOpenAppleTalkServices(VAR cfig: OTConfiguration; flags: OTOpenFlags; VAR err: OSStatus): ATSvcRef;
  209. {}
  210. { Get the zone associated with the ATSvcRef}
  211. {}
  212. FUNCTION OTATalkGetMyZone(ref: ATSvcRef; VAR zone: TNetbuf): OSStatus;
  213. {}
  214. { Get the list of available zones associated with the local cable}
  215. { of the ATSvcRef}
  216. {}
  217. FUNCTION OTATalkGetLocalZones(ref: ATSvcRef; VAR zones: TNetbuf): OSStatus;
  218. {}
  219. { Get the list of all zones on the internet specified by the ATSvcRef}
  220. {}
  221. FUNCTION OTATalkGetZoneList(ref: ATSvcRef; VAR zones: TNetbuf): OSStatus;
  222. {}
  223. { Stores an AppleTalkInfo structure into the TNetbuf (see later in this file)}
  224. {}
  225. FUNCTION OTATalkGetInfo(ref: ATSvcRef; VAR info: TNetbuf): OSStatus;
  226. {$ENDC}
  227.  
  228. TYPE
  229.     DDPAddress = RECORD
  230.         fAddressType:            OTAddressType;
  231.         fNetwork:                UInt16;
  232.         fNodeID:                SInt8; (* UInt8 *)
  233.         fSocket:                SInt8; (* UInt8 *)
  234.         fDDPType:                SInt8; (* UInt8 *)
  235.         fPad:                    SInt8; (* UInt8 *)
  236.     END;
  237.  
  238.     NBPAddress = RECORD
  239.         fAddressType:            OTAddressType;
  240.         fNBPNameBuffer:            ARRAY [0..kNBPEntityBufferSize-1] OF SInt8; (* UInt8 *)
  241.     END;
  242.  
  243.     DDPNBPAddress = RECORD
  244.         fAddressType:            OTAddressType;
  245.         fNetwork:                UInt16;
  246.         fNodeID:                SInt8; (* UInt8 *)
  247.         fSocket:                SInt8; (* UInt8 *)
  248.         fDDPType:                SInt8; (* UInt8 *)
  249.         fPad:                    SInt8; (* UInt8 *)
  250.         fNBPNameBuffer:            ARRAY [0..kNBPEntityBufferSize-1] OF SInt8; (* UInt8 *)
  251.     END;
  252.  
  253.     NBPEntity = RECORD
  254.         fEntity:                ARRAY [0..kNBPMaxEntityLength-1] OF SInt8; (* UInt8 *)
  255.     END;
  256.  
  257. {    ---------------------------------------------------------------------
  258.         These are some utility routines for dealing with NBP and DDP addresses. 
  259.         --------------------------------------------------------------------- }
  260. {}
  261. { Functions to initialize the various AppleTalk Address types}
  262. {}
  263.  
  264. PROCEDURE OTInitDDPAddress(VAR addr: DDPAddress; net: UInt16; node: ByteParameter; socket: ByteParameter; ddpType: ByteParameter);
  265. FUNCTION OTInitNBPAddress(VAR addr: NBPAddress; name: ConstCStringPtr): size_t;
  266. FUNCTION OTInitDDPNBPAddress(VAR addr: DDPNBPAddress; name: ConstCStringPtr; net: UInt16; node: ByteParameter; socket: ByteParameter; ddpType: ByteParameter): size_t;
  267. {}
  268. { Compare 2 DDP addresses for equality}
  269. {}
  270. FUNCTION OTCompareDDPAddresses({CONST}VAR addr1: DDPAddress; {CONST}VAR addr2: DDPAddress): BOOLEAN;
  271. {}
  272. { Init an NBPEntity to a NULL name}
  273. {}
  274. PROCEDURE OTInitNBPEntity(VAR entity: NBPEntity);
  275. {}
  276. { Get the length an NBPEntity would have when stored as an address}
  277. { }
  278. FUNCTION OTGetNBPEntityLengthAsAddress({CONST}VAR entity: NBPEntity): size_t;
  279. {}
  280. { Store an NBPEntity into an address buffer}
  281. {}
  282. FUNCTION OTSetAddressFromNBPEntity(VAR nameBuf: UInt8; {CONST}VAR entity: NBPEntity): size_t;
  283. {}
  284. { Create an address buffer from a string (use -1 for len to use strlen)}
  285. {}
  286. FUNCTION OTSetAddressFromNBPString(VAR addrBuf: UInt8; name: ConstCStringPtr; len: SInt32): size_t;
  287. {}
  288. { Create an NBPEntity from an address buffer. False is returned if}
  289. {   the address was truncated.}
  290. {}
  291. FUNCTION OTSetNBPEntityFromAddress(VAR entity: NBPEntity; {CONST}VAR addrBuf: UInt8; len: size_t): BOOLEAN;
  292. {}
  293. { Routines to set a piece of an NBP entity from a character string}
  294. {}
  295. FUNCTION OTSetNBPName(VAR entity: NBPEntity; name: ConstCStringPtr): BOOLEAN;
  296. FUNCTION OTSetNBPType(VAR entity: NBPEntity; typeVal: ConstCStringPtr): BOOLEAN;
  297. FUNCTION OTSetNBPZone(VAR entity: NBPEntity; zone: ConstCStringPtr): BOOLEAN;
  298. {}
  299. { Routines to extract pieces of an NBP entity}
  300. {}
  301. PROCEDURE OTExtractNBPName({CONST}VAR entity: NBPEntity; name: CStringPtr);
  302. PROCEDURE OTExtractNBPType({CONST}VAR entity: NBPEntity; typeVal: CStringPtr);
  303. PROCEDURE OTExtractNBPZone({CONST}VAR entity: NBPEntity; zone: CStringPtr);
  304.  
  305. CONST
  306.     AF_ATALK_FAMILY                = $0100;
  307.     AF_ATALK_DDP                = AF_ATALK_FAMILY;
  308.     AF_ATALK_DDPNBP                = AF_ATALK_FAMILY + 1;
  309.     AF_ATALK_NBP                = AF_ATALK_FAMILY + 2;
  310.     AF_ATALK_MNODE                = AF_ATALK_FAMILY + 3;
  311.  
  312. {    -------------------------------------------------------------------------
  313.         AppleTalkInfo - filled out by the OTGetATalkInfo function
  314.     ------------------------------------------------------------------------- }
  315.  
  316. TYPE
  317.     AppleTalkInfo = RECORD
  318.         fOurAddress:            DDPAddress;                                { Our DDP address (network # & node)}
  319.         fRouterAddress:            DDPAddress;                                { The address of a router on our cable}
  320.         fCableRange:            ARRAY [0..1] OF UInt16;                    { The current cable range}
  321.         fFlags:                    UInt16;                                    { See below}
  322.     END;
  323.  
  324. {}
  325. { For the fFlags field in AppleTalkInfo}
  326. {}
  327.  
  328. CONST
  329.     kATalkInfoIsExtended        = $0001;                        { This is an extended (phase 2) network}
  330.     kATalkInfoHasRouter            = $0002;                        { This cable has a router}
  331.     kATalkInfoOneZone            = $0004;                        { This cable has only one zone}
  332.  
  333.  
  334. {$SETC UsingIncludes := OpenTptAppleTalkIncludes}
  335.  
  336. {$ENDC} {__OPENTPTAPPLETALK__}
  337.  
  338. {$IFC NOT UsingIncludes}
  339.  END.
  340. {$ENDC}
  341.